// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    name: 'ComstarSoft',
    locale: true,
    siderWidth: 208,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      layout: false,
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      path: '/welcome',
      name: 'welcome',
      icon: 'DashboardOutlined',
      component: './Welcome',
    },
    {
      path: '/opmanage/members',
      name: 'members',
      icon: 'icon-conference_call',
      component: './opmanage/members',
      access: 'DoctorDistributorResourcer',
    },
    {
      path: '/account',
      name: 'account',
      icon: 'icon-businessman',
      access: 'canAdmin',
      routes: [
        {
          path: '/account/setting',
          name: 'setting',
          component: './account/setting',
        },
      ]
    },
    {
      path: '/promage',
      name: 'promage',
      icon: 'icon-advertising',
      routes: [
        {
          path: '/promage/advertisement',
          name: 'advertisement',
          component: './opmanage/advertisement',
          access: 'canAdmin',
        },
        {
          path: '/promage/promotion',
          name: 'promotion',
          component: './opmanage/promotion',
          access: 'canAdmin',
        },
        {
          path: '/promage/coupon',
          name: 'coupon',
          component: './opmanage/coupon',
          access: 'canAdmin',
        },
        {
          path: '/promage/keywords',
          name: 'keywords',
          component: './opmanage/keywords',
          access: 'canAdmin',
        },
      ]
    },
    {
      path: '/opmanage',
      name: 'opmanage',
      icon: 'icon-idea',
      routes: [

        {
          path: '/opmanage/courses',
          name: 'courses',
          component: './opmanage/courses',
          access: 'canResourcer',
        },
        {
          path: '/opmanage/coursesCopy',
          name: 'coursesCopy',
          component: './opmanage/coursesCopy',
          access: 'canResourcer',
        },
        {
          path: '/opmanage/childrens',
          name: 'childrens',
          component: './opmanage/childrens',
          access: 'canDoctor',
        },
        {
          path: '/opmanage/product',
          name: 'product',
          component: './opmanage/product',
          access: 'canAdmin',
        },
        
        {
          path: '/opmanage/orders',
          name: 'orders',
          component: './opmanage/orders',
          access: 'DoctorDistributorResourcer',
        },
        {
          path: '/opmanage/vaccines',
          name: 'vaccines',
          component: './opmanage/vaccines',
          access: 'canAdmin',
        },
        {
          path: '/opmanage/doctors',
          name: 'doctors',
          component: './opmanage/doctors',
          access: 'canAdmin',
        },
        {
          path: '/opmanage/feton',
          name: 'feton',
          component: './opmanage/feton',
          access: 'canAdmin',
        },
        {
          path: '/opmanage/bmi',
          name: 'bmi',
          component: './opmanage/bmi',
          access: 'canAdmin',
        },
        {
          path: '/opmanage/question',
          name: 'question',
          component: './opmanage/question',
          access: 'canAdmin',
        },        
        {
          path: '/opmanage/opconfig',
          name: 'opconfig',
          component: './opmanage/opconfig',
          access: 'canAdmin',
        },
        {
          path:'/opmanage/advise',
          name:'advise',
          component:'./opmanage/advise',
          access:'canAdmin',
        }
      ],
    },
    {
      path: '/distribute',
      name: 'distribute',
      icon: 'icon-contacts',
      access: 'canAdmin',
      routes: [
        {
          path: '/distribute/list',
          name: 'list',
          component: './opmanage/distribute',
        },
      ],
    },
    {
      path: '/finance',
      name: 'finance',
      icon: 'icon-positive_dynamic',
      access: 'canAdmin',
      routes: [
        {
          path: '/finance/list',
          name: 'list',
          component: './ListTableList',
        },
        {
          path: '/finance/cashApply',
          name: 'cashApply',
          component: './opmanage/cashApply',
        },
      ],
    },
    {
      path: '/admin',
      name: 'admin',
      icon: 'icon-services',
      access: 'canAdmin',
      routes: [
        {
          path: '/admin/department',
          name: 'department',
          component: './admin/department',
        },
        {
          path: '/admin/roles',
          name: 'roles',
          component: './admin/roles',
        },
        {
          path: '/admin/files',
          name: 'files',
          component: './admin/files',
        },
        {
          path: '/admin/content',
          name: 'content',
          component: './admin/content',
        },
        {
          path: '/admin/contEdit',
          name: 'contEdit',
          hideInMenu: true,
          component: './admin/contEdit',
        },
      ],
    },
    {
      path: '/',
      redirect: '/welcome',
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'pre'],
  manifest: {
    basePath: '/',
  },
});
